#include "platform.h"
#include "compress.h"
#include <zlib.h>


uint32_t zlib_buffer_inflate(void* dest, uint32_t destlen, const void* src, uint32_t srclen)
{
	uLongf result = destlen;
	if( uncompress((Bytef*)dest, &result, (Bytef*)src, srclen) != Z_OK )
		return 0;
	return result;
}


uint32_t zlib_buffer_deflate(void* dest, uint32_t destlen, const void* src, uint32_t srclen, int level)
{
	uLongf result = destlen;
	if( compress2((Bytef*)dest, &result, (Bytef*)src, srclen, level) != Z_OK )
		return 0;
	return result;
}


uint32_t zlib_compressbound(uint32_t srclen)
{
	return compressBound(srclen);
}


int zlib_default_level(void)
{
	return Z_DEFAULT_COMPRESSION;
}


const char* zlib_version_string(void)
{
	return zlibVersion();
}
